#!/usr/bin/env python
# -*- coding:utf-8 -*-
import Stemmer
import os, sys

def main():
    txtfile = open(sys.argv[1] + ".out2",'r')
    txt = txtfile.read()
    txtfile.close()

    stemmer = Stemmer.Stemmer('spanish')
    stemmed = stemmer.stemWords(txt.split(" "))

    outfile = open(sys.argv[1] + ".out3", 'w')
    
    firstword = True

    for w in stemmed:
        outfile.write(("" if firstword else " ") + w)
        firstword = False

    outfile.close()

if __name__ == "__main__":
    main()
   
